// store/modules/translate.js
import {getText} from  '@/common/utils.js'
export default {
  namespaced: true,
  state: {
    language: 0,  // 0: 中文, 1: 英文
  },
  mutations: {
    setLanguage(state, language) {
		uni.setStorageSync('language',language)
		uni.setTabBarItem({
			index:0,text:getText('主页')
		})
		uni.setTabBarItem({
			index:1,text:getText('分类')
		})
		uni.setTabBarItem({
			index:2,text:getText('发现')
		})
		uni.setTabBarItem({
			index:3,text:getText('购物车')
		})
		
		uni.setTabBarItem({
			index:4,text:getText('我的')
		})
      state.language = language;
    }
  },
  actions: {
    switchLanguage({ commit }, language) {
		

      commit('setLanguage', language);
	  
    }
  },
  getters: {
    currentLanguage: state => state.language,
  }
}